#include<iostream>
using namespace std;
int  x;
int fun(int n)
{
	int count = 0;
	int t = 0;
	while (n) {
		t = n % 10;
		if (t == x) {
			count++;
		}
		n /= 10;
	}
	return count;
}
int main()
{
	int n;
	cin >> n >> x;
	int count = 0;
	for (int i = 1; i < n + 1; i++) {
		count += fun(i);
	}
	cout << count << endl;
	return 0;
}
